---
title: Spec - howl.ui.ActionBuffer
tags: spec
---
<div class="spec-group spec-group-1">

<h1 id="howl.ui.actionbuffer">howl.ui.ActionBuffer</h1>

<pre class="highlight moonscript"><code><span class="n">buf</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">ActionBuffer</span><span class="o">!</span><span class="w">

</span><span class="n">before_each</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="n">buf</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">''</span></code></pre>


<h4 id="behaves-like-a-buffer">behaves like a Buffer</h4>

<pre class="highlight moonscript"><code><span class="n">buf</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hello'</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">buf</span><span class="p">.</span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="s1">'hello'</span><span class="w">
</span><span class="n">buf</span><span class="o">\</span><span class="n">append</span><span class="w"> </span><span class="s1">' world'</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="n">buf</span><span class="p">.</span><span class="n">text</span><span class="p">,</span><span class="w"> </span><span class="s1">'hello world'</span></code></pre>


<h4 id="does-not-collection-undo-revisions-by-default">does not collection undo revisions by default</h4>

<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">is_false</span><span class="w"> </span><span class="nc">ActionBuffer</span><span class="p">().</span><span class="n">collect_revisions</span></code></pre>

<div class="spec-group spec-group-2">

<h2 id=".insert(object,-pos[-,-style])">.insert(object, pos[ , style])</h2>
<div class="spec-group spec-group-3">

<h3 id="(with-no-specified-style)">(with no specified style)</h3>

<h4 id="inserts-the-object-with-no-specific-style-and-returns-the-next-position">inserts the object with no specific style and returns the next position</h4>

<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">6</span><span class="p">,</span><span class="w"> </span><span class="n">buf</span><span class="o">\</span><span class="n">insert</span><span class="w"> </span><span class="s1">'hello'</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'hello'</span><span class="p">,</span><span class="w"> </span><span class="n">buf</span><span class="p">.</span><span class="n">text</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">is_nil</span><span class="w"> </span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">)</span></code></pre>


<h4 id="returns-&lt;pos&gt;-and-leaves-the-buffer-untouched-for-an-empty-string">returns &lt;pos&gt; and leaves the buffer untouched for an empty string</h4>

<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">buf</span><span class="o">\</span><span class="n">insert</span><span class="p">(</span><span class="s1">''</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">)</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span><span class="w"> </span><span class="n">buf</span><span class="p">.</span><span class="n">text</span></code></pre>

</div>
<div class="spec-group spec-group-3">

<h3 id="(with-style-specified)">(with style specified)</h3>

<h4 id="styles-the-object-with-the-specified-style">styles the object with the specified style</h4>

<pre class="highlight moonscript"><code><span class="n">buf</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'˫˫'</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">7</span><span class="p">,</span><span class="w"> </span><span class="n">buf</span><span class="o">\</span><span class="n">insert</span><span class="p">(</span><span class="s1">'hƏllo'</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="s1">'keyword'</span><span class="p">)</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">is_nil</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">))</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'keyword'</span><span class="p">,</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">))</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'keyword'</span><span class="p">,</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">6</span><span class="p">))</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">is_nil</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">7</span><span class="p">))</span></code></pre>


<h4 id="returns-&lt;pos&gt;-and-leaves-the-buffer-untouched-for-an-empty-string">returns &lt;pos&gt; and leaves the buffer untouched for an empty string</h4>

<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">buf</span><span class="o">\</span><span class="n">insert</span><span class="p">(</span><span class="s1">''</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="s1">'keyword'</span><span class="p">)</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">''</span><span class="p">,</span><span class="w"> </span><span class="n">buf</span><span class="p">.</span><span class="n">text</span></code></pre>

</div>
<div class="spec-group spec-group-3">

<h3 id="(when-object-is-a-styled-object-(.styles-is-present))">(when object is a styled object (.styles is present))</h3>

<h4 id="inserts-the-corresponding-.text-and-returns-the-next-position">inserts the corresponding .text and returns the next position</h4>

<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="n">buf</span><span class="o">\</span><span class="n">insert</span><span class="p">(</span><span class="s1">'foo'</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">)</span><span class="w">
</span><span class="n">chunk</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">buf</span><span class="o">\</span><span class="n">chunk</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">)</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">7</span><span class="p">,</span><span class="w"> </span><span class="n">buf</span><span class="o">\</span><span class="n">insert</span><span class="w"> </span><span class="n">chunk</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'foofoo'</span><span class="p">,</span><span class="w"> </span><span class="n">buf</span><span class="p">.</span><span class="n">text</span></code></pre>


<h4 id="styles-the-inserted-.text-using-.styles-for-the-styling">styles the inserted .text using .styles for the styling</h4>

<pre class="highlight moonscript"><code><span class="n">buf</span><span class="o">\</span><span class="n">insert</span><span class="w"> </span><span class="p">{</span><span class="ss">text:</span><span class="w"> </span><span class="s1">'styled'</span><span class="p">,</span><span class="w"> </span><span class="ss">styles:</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="s1">'keyword'</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="s1">'number'</span><span class="p">,</span><span class="w"> </span><span class="mi">6</span><span class="w"> </span><span class="p">}},</span><span class="w"> </span><span class="mi">1</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">is_nil</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">))</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'keyword'</span><span class="p">,</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">))</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'number'</span><span class="p">,</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">))</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'number'</span><span class="p">,</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">5</span><span class="p">))</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">is_nil</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">6</span><span class="p">))</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'styled'</span><span class="p">,</span><span class="w"> </span><span class="n">buf</span><span class="p">.</span><span class="n">text</span></code></pre>


<h4 id="still-returns-the-next-position">still returns the next position</h4>

<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">buf</span><span class="o">\</span><span class="n">insert</span><span class="w"> </span><span class="nc">StyledText</span><span class="p">(</span><span class="s1">'åö'</span><span class="p">,</span><span class="w"> </span><span class="p">{}),</span><span class="w"> </span><span class="mi">1</span></code></pre>


<h4 id="ignores-any-given-&lt;style&gt;-parameter">ignores any given &lt;style&gt; parameter</h4>

<pre class="highlight moonscript"><code><span class="n">buf</span><span class="o">\</span><span class="n">insert</span><span class="w"> </span><span class="nc">StyledText</span><span class="p">(</span><span class="s1">'foo'</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="s1">'number'</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span><span class="w"> </span><span class="p">}),</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="s1">'keyword'</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'number'</span><span class="p">,</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">))</span></code></pre>

</div>
</div>
<div class="spec-group spec-group-2">

<h2 id=".append(text,-style)">.append(text, style)</h2>
<div class="spec-group spec-group-3">

<h3 id="(with-no-specified-style)">(with no specified style)</h3>

<h4 id="appends-the-text-with-no-specific-style-and-returns-the-next-position">appends the text with no specific style and returns the next position</h4>

<pre class="highlight moonscript"><code><span class="n">buf</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hello'</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="o">#</span><span class="s1">'hello world'</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="n">buf</span><span class="o">\</span><span class="n">append</span><span class="w"> </span><span class="s1">' world'</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">is_nil</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">7</span><span class="p">))</span></code></pre>

</div>
<div class="spec-group spec-group-3">

<h3 id="(with-style-specified)">(with style specified)</h3>

<h4 id="styles-the-text-with-the-specified-style">styles the text with the specified style</h4>

<pre class="highlight moonscript"><code><span class="n">buf</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'˫'</span><span class="w">
</span><span class="n">buf</span><span class="o">\</span><span class="n">append</span><span class="w"> </span><span class="s1">'hƏllo'</span><span class="p">,</span><span class="w"> </span><span class="s1">'keyword'</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">is_nil</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">))</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'keyword'</span><span class="p">,</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">))</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'keyword'</span><span class="p">,</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">6</span><span class="p">))</span></code></pre>

</div>
<div class="spec-group spec-group-3">

<h3 id="(when-object-is-a-styled-object)">(when object is a styled object)</h3>

<h4 id="appends-the-corresponding-text-and-returns-the-next-position">appends the corresponding text and returns the next position</h4>

<pre class="highlight moonscript"><code><span class="n">buf</span><span class="o">\</span><span class="n">insert</span><span class="w"> </span><span class="s1">'foo'</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="w">
</span><span class="n">chunk</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">buf</span><span class="o">\</span><span class="n">chunk</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">)</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equals</span><span class="w"> </span><span class="mi">7</span><span class="p">,</span><span class="w"> </span><span class="n">buf</span><span class="o">\</span><span class="n">append</span><span class="w"> </span><span class="n">chunk</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'foofoo'</span><span class="p">,</span><span class="w"> </span><span class="n">buf</span><span class="p">.</span><span class="n">text</span></code></pre>


<h4 id="styles-the-inserted-text-using-.styles-for-the-styling">styles the inserted text using .styles for the styling</h4>

<pre class="highlight moonscript"><code><span class="n">buf</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'foo'</span><span class="w">
</span><span class="n">object</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">StyledText</span><span class="p">(</span><span class="s1">'bar'</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="s1">'number'</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="s1">'keyword'</span><span class="p">,</span><span class="w"> </span><span class="mi">3</span><span class="p">})</span><span class="w">
</span><span class="n">buf</span><span class="o">\</span><span class="n">insert</span><span class="w"> </span><span class="n">object</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'foobar'</span><span class="p">,</span><span class="w"> </span><span class="n">buf</span><span class="p">.</span><span class="n">text</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'number'</span><span class="p">,</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span><span class="p">))</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'keyword'</span><span class="p">,</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">5</span><span class="p">))</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">is_nil</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">6</span><span class="p">))</span></code></pre>


<h4 id="still-returns-the-next-position">still returns the next position</h4>

<pre class="highlight moonscript"><code><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="mi">3</span><span class="p">,</span><span class="w"> </span><span class="n">buf</span><span class="o">\</span><span class="n">append</span><span class="w"> </span><span class="nc">StyledText</span><span class="p">(</span><span class="s1">'åö'</span><span class="p">,</span><span class="w"> </span><span class="p">{})</span></code></pre>


<h4 id="ignores-any-given-&lt;style&gt;-parameter">ignores any given &lt;style&gt; parameter</h4>

<pre class="highlight moonscript"><code><span class="n">buf</span><span class="o">\</span><span class="n">append</span><span class="w"> </span><span class="nc">StyledText</span><span class="p">(</span><span class="s1">'foo'</span><span class="p">,</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="s1">'number'</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span><span class="w"> </span><span class="p">}),</span><span class="w"> </span><span class="s1">'keyword'</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'number'</span><span class="p">,</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">))</span></code></pre>

</div>
</div>
<div class="spec-group spec-group-2">

<h2 id="style(start_pos,-end_pos,-style)">style(start_pos, end_pos, style)</h2>

<h4 id="applies-&lt;style&gt;-for-the-inclusive-text-range-given">applies &lt;style&gt; for the inclusive text range given</h4>

<pre class="highlight moonscript"><code><span class="n">buf</span><span class="p">.</span><span class="n">text</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s1">'hƏlɩo'</span><span class="w">
</span><span class="n">buf</span><span class="o">\</span><span class="n">style</span><span class="w"> </span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span><span class="p">,</span><span class="w"> </span><span class="s1">'keyword'</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">is_nil</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">1</span><span class="p">))</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'keyword'</span><span class="p">,</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">2</span><span class="p">))</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">equal</span><span class="w"> </span><span class="s1">'keyword'</span><span class="p">,</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">4</span><span class="p">))</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">is_nil</span><span class="w"> </span><span class="p">(</span><span class="n">style</span><span class="p">.</span><span class="n">at_pos</span><span class="p">(</span><span class="n">buf</span><span class="p">,</span><span class="w"> </span><span class="mi">5</span><span class="p">))</span></code></pre>

</div>
<div class="spec-group spec-group-2">

<h3 id="(resource-management)">(resource management)</h3>

<h4 id="buffers-are-collected-properly">buffers are collected properly</h4>

<pre class="highlight moonscript"><code><span class="n">b</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nc">ActionBuffer</span><span class="o">!</span><span class="w">
</span><span class="n">buffers</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="nb">setmetatable</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">b</span><span class="w"> </span><span class="p">},</span><span class="w"> </span><span class="ss">__mode:</span><span class="w"> </span><span class="s1">'v'</span><span class="w">
</span><span class="n">b</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="kc">nil</span><span class="w">
</span><span class="nb">collectgarbage</span><span class="o">!</span><span class="w">
</span><span class="n">assert</span><span class="p">.</span><span class="n">is_nil</span><span class="w"> </span><span class="n">buffers</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span></code></pre>

</div>
</div>
